<%--
  Created by IntelliJ IDEA.
  User: A
  Date: 2024/4/7
  Time: 8:42
  To change this template use File | Settings | File Templates.
--%>
<%@ page isELIgnored="false" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<html>
<head>
    <title>主页</title>
    <link rel="stylesheet" type="text/css" href="/static/layui/css/layui.css"/>
    <link rel="stylesheet" href="../../static/layui/css/layui.css">
    <script src="../../static/jquery-2.1.4.js" type="text/javascript" charset="utf-8"></script>
    <script src="../../static/layui/layui.js" type="text/javascript" charset="utf-8"></script>
    <script src="../../static/mylayer.js" type="text/javascript" charset="utf-8"></script>
    <style>
        .avatar-img {
            width: 50px; /* 设置头像图片的宽度 */
            height: 50px; /* 设置头像图片的高度，可以根据需要调整 */
            border-radius: 50%; /* 使图片呈现圆形 */
            margin-right: 10px; /* 设置头像图片与用户名之间的间距，可以根据需要调整 */
        }
    </style>
</head>
<body class="layui-layout-body">
<div class="layui-layout layui-layout-admin">
    <div class="layui-header">
        <div class="layui-logo layui-hide-xs">
            <img src="./static/pic/xx-logo.png" style="width: 200px ;height: 50px" alt="">
        </div>
        <ul class="layui-nav layui-layout-left">   </ul>
        <ul class="layui-nav layui-layout-right">
            <li class="layui-nav-item">
<%--                <a href="javascript:;">--%>
<%--                    <img width="40px" height="30px" src="/pic/${admin.avatar}"/> ${admin.username}--%>
<%--                </a>--%>
                <a href="javascript:;">
                    <img class="avatar-img" src="/pic/${admin.avatar}"/>
                    ${admin.username}
                </a>
                <dl class="layui-nav-child">
                    <dd>
                        <a href="javascript:;"
                           data-url="page/admininfo" class="site-demo-active">基本资料</a>
                    </dd>
                    <dd>
                        <a href="javascript:openInfo()">修改资料</a>
                    </dd>
                    <dd>
                        <a href="javascript:openPass()">修改密码</a>
                    </dd>
                </dl>
            </li>
            <li class="layui-nav-item">
                <a href="javascript:logout()">注销</a>
            </li>
        </ul>
    </div>
    <div class="layui-side layui-bg-green">
        <div class="layui-side-scroll">
            <!-- 左侧导航区域（可配合layui已有的垂直导航） -->
            <ul class="layui-nav layui-nav-tree layui-bg-green" >
                <li class="layui-nav-item layui-nav-itemed">
                    <a href="javascript:;">租赁系统信息管理</a>
                    <dl class="layui-nav-child">
                        <c:forEach items="${roleVos}" var="auth">
                            <c:choose>
                                <c:when test="${auth.id >= 2 && auth.id <= 6}">
                                    <dd>
                                        <a href="javascript:;"
                                           data-url="${auth.path}"
                                           class="site-demo-active">${auth.permissionName}</a>
                                    </dd>
                                </c:when>
                            </c:choose>
                        </c:forEach>
                    </dl>
                </li>
                <li class="layui-nav-item">
                    <a href="javascript:;">管理员信息管理</a>
                    <dl class="layui-nav-child">
                        <c:forEach items="${roleVos}" var="auth">
                            <c:choose>
                                <c:when test="${auth.roleId == 1}">
                                    <c:choose>
                                        <c:when test="${auth.id == 1 || auth.id == 7}">
                                            <dd>
                                                <a href="javascript:;"
                                                   data-url="${auth.path}"
                                                   class="site-demo-active">${auth.permissionName}</a>
                                            </dd>
                                        </c:when>
                                    </c:choose>
                                </c:when>
                                <c:otherwise>
                                    <c:choose>
                                        <c:when test="${auth.id == 7}">
                                            <dd>
                                                <a href="javascript:;"
                                                   data-url="${auth.path}"
                                                   class="site-demo-active">${auth.permissionName}</a>
                                            </dd>
                                        </c:when>
                                    </c:choose>
                                </c:otherwise>
                            </c:choose>
                        </c:forEach>
                    </dl>
                </li>
            </ul>
        </div>
    </div>
    <div class="layui-body"><!-- 内容主体区域 -->
        <iframe name="rightframe" width="100%" height="100%" src="/page/echarts"></iframe>
    </div>
<%--    <div class="layui-footer">© JAVA - 底部固定区域</div>--%>
</div>
<script type="text/javascript">
    var $ = layui.jquery;
    var layer = layui.layer;
    var element = layui.element;
    $('.site-demo-active').click(function() {
        window.open($(this).data('url'), "rightframe");
    });
    element.render();// element.init();
    function openURL(url){
        window.open(url, "rightframe");
    }
    function openInfo() {
        layer.open({
            title: '修改个人信息',
            type: 2,
            area: ['35%', '90%'],// 宽高
            content: '/page/admininfo/updateinfo?id='+${admin.id},
        });
    }
    function openPass() {
        layer.open({
            title: '修改密码',
            type: 2,
            area: ['35%', '60%'],// 宽高
            content: '/page/admininfo/updatepassword?id='+${admin.id},
        });
    }
    function logout() {
        layer.confirm(
            '您确认要退出么',
            {icon:3},
            function() {
                $.post(
                    '/admin?method=logout',
                    function (result) {
                        if (result.code == 0) {
                            mylayer.okUrl(result.msg, '/page/login');
                        }
                    },
                    'json'
                );
                // location.href = '/admin?method=logout'
            }
        );
    }
</script>
</body>
</html>
